<!DOCTYPE html>
<!-- saved from url=(0060)http://pp.ecer.com/index.php?r=product/edit&pid=18003&page=1 -->
<html lang="en" class=" ieundefined" data-dpr="1" style="font-size: 140px;">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Expires" content="0">

    <title>产品编辑</title>
    <link rel="shortcut icon" href="http://pp.ecer.com/favicon.ico" type="image/x-icon">
    <link href="./产品编辑_files/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="./产品编辑_files/font_1630532_vhi20rq6u5r.css">
    <link rel="stylesheet" href="./产品编辑_files/common.css">

    <script type="text/javascript" src="./产品编辑_files/jq3.4.1.js.下载"></script>
    <script type="text/javascript" src="./产品编辑_files/Sortable.min.js.下载"></script>
    <script type="text/javascript" src="./产品编辑_files/wangEditor.min.js.下载"></script>

    <div class="main-body">

        <section class="container-fluid section">
            <div class="mainMaxWidth Editsetion">
                <div class="section-header">
                    <div class="text">
                        <span>产品编辑</span>
                        <span></span>
                    </div>
                    <div class="item">
                        <div class="new-pro cur save">
                            <span class="fontdef  ">保存</span>
                        </div>
                        <div class="new-pro clear cur cancel">
                            <span class="fontdef  ">取消</span>
                        </div>
                    </div>
                </div>
                <div class="section-main edit-main">
                    <div class=" prod-name">
                        <h5 class="text99">产品标题</h5>
                        <div class="line">
                            <input id="pid" type="hidden" value="18003" autocomplete="new-password">
                            <input id="title" type="text" value="123123123123123" autocomplete="new-password">
                            <span id="title_error"></span>
                        </div>
                    </div>
                    <div class=" prod-name prod-img">
                        <h5 class="text99">产品图片</h5>
                        <div class="imgupload">
                            <ul>
                                <li>
                                    <img src="./产品编辑_files/31a84a06964fb4bcb9448625acb4.jpg" alt="">
                                    <input type="hidden"
                                        value="http://cimg.everychina.com/img/ef/ac/31a84a06964fb4bcb9448625acb4.jpg"
                                        name="images" autocomplete="new-password">
                                    <div class="del cur"><i class="iconfont icon-shanchu"></i> <span>删除</span></div>
                                </li>
                                <li class="upload">
                                    <div style="position: absolute">
                                        <i class="iconfont icon-xinzeng"></i>
                                        <span>插入图片</span>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <input id="file" enctype="" onchange="uploadImg();" style="opacity:0;height: 0;width: 0;"
                        type="file" name="file" autocomplete="new-password">
                    <div class=" prod-name prod-edit">
                        <h5 class="text99">详情描述</h5>
                        <div class="edit pc">
                            <div id="Editor">
                                <div style="background-color:#f1f1f1; border:1px solid #ccc;" class="w-e-toolbar"
                                    id="toolbar-elem1784670067593781">
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-header"></i></div>
                                    <div class="w-e-menu" style="z-index:101;">
                                        <i class="w-e-icon-bold"></i>
                                    </div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-text-heigh"></i></div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-font"></i></div>
                                    <div class="w-e-menu" style="z-index:101;">
                                        <i class="w-e-icon-italic"></i>
                                    </div>
                                    <div class="w-e-menu" style="z-index:101;">
                                        <i class="w-e-icon-underline"></i>
                                    </div>
                                    <div class="w-e-menu" style="z-index:101;">
                                        <i class="w-e-icon-strikethrough"></i>
                                    </div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-pencil2"></i></div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-paint-brush"></i>
                                    </div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-link"></i></div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-list2"></i></div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-paragraph-left"></i>
                                    </div>
                                    <div class="w-e-menu" style="z-index:101;"><i class="w-e-icon-table2"></i></div>
                                    <div class="w-e-menu" style="z-index:101;">
                                        <i class="w-e-icon-undo"></i>
                                    </div>
                                    <div class="w-e-menu" style="z-index:101;">
                                        <i class="w-e-icon-redo"></i>
                                    </div>
                                    <div class="w-e-menu" id="w-e-img24206406614439913" style="z-index:101;"><i
                                            class="w-e-icon-image"></i></div>
                                </div>
                                <div style="border:1px solid #ccc; border-top:none; height:300px; z-index:100;"
                                    class="w-e-text-container">
                                    <div contenteditable="true" style="width:100%; height:100%;" class="w-e-text"
                                        id="text-elem6234123148401431">
                                        <p>撒打发士大夫啊手动阀 撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀&nbsp;
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="edit phone">
                            <div id="content" class="div w-e-text" contenteditable="true">
                                <p>撒打发士大夫啊手动阀 撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀&nbsp;</p>
                            </div>
                            <div class="btnt">
                                <div style="margin-right: 16px" class="cur" id="line_feed">换行</div>
                                <div class="cur" id="insert_pic">插入图片</div>
                            </div>
                        </div>
                        <span id="words_error"></span>
                    </div>














                    <!-- 新增归属分类 start  -->
                    <style>
                        .edit-main .prod-class {
                            margin-top: 12px;
                        }

                        .edit-main .prod-class .select {
                            width: 50%;
                            height: 37px;
                            background: rgba(255, 255, 255, 1);
                            border: 1px solid rgba(217, 217, 217, 1);
                            box-sizing: border-box;
                            padding: 0 15px;
                            position: relative;
                        }

                        .edit-main .prod-class .select .input {
                            position: relative;
                        }

                        .edit-main .prod-class .select span {
                            height: 35px;
                            line-height: 35px;
                            font-size: 14px;
                            color: rgba(51, 51, 51, 1);
                            white-space: nowrap;
                            width: 100%;
                            overflow: hidden;
                            display: block;
                        }

                        .edit-main .prod-class .select ul {
                            position: absolute;
                            top: 37px;
                            width: 100%;
                            left: 0;
                            background: rgba(255, 255, 255, 1);
                            border: 1px solid rgba(221, 221, 221, 1);
                            box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.12);
                            opacity: 1;
                            margin-bottom: 16px;
                            display: none;
                        }

                        .edit-main .prod-class .select ul li {
                            height: 37px;
                            line-height: 37px;
                            padding: 0 16px;
                            cursor: pointer;
                            user-select: none;
                        }

                        .edit-main .prod-class .select ul li:hover {
                            background: rgba(245, 245, 245, 1);
                        }

                        .edit-main .prod-class .select .openbtn {
                            width: 0;
                            height: 0;
                            border: 8px solid #D9D9D9;
                            border-color: rgb(201, 201, 201) transparent transparent transparent;
                            position: absolute;
                            right: -10px;
                            top: 50%;
                            transform: translateY(-50%);
                            margin-top: 5px;
                            cursor: pointer;
                        }

                        .edit-main .prod-class .select .closebtn {
                            width: 0;
                            height: 0;
                            border: 8px solid #D9D9D9;
                            border-color: transparent transparent rgb(201, 201, 201) transparent;
                            position: absolute;
                            right: -10px;
                            top: 50%;
                            transform: translateY(-50%);
                            margin-top: -5px;
                            cursor: pointer;

                        }
                        @media (max-width: 768px){
                            .edit-main .prod-class .select{
                                width: 100%;
                            }
                        }
                    </style>
                    <div class=" prod-name prod-class">
                        <h5 class="text99">归属分类</h5>
                        <div class="select" id="select-ecer">
                            <div class="input">
                                <span>我是默认分类啊 ！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！</span>
                                <div class="openbtn" id="openSelect"></div>
                            </div>
                            <ul>
                                <li>123123123</li>
                                <li>234324234</li>
                                <li>435345345</li>
                                <li>645645645</li>
                            </ul>
                        </div>
                    </div>
                    <script>
                        $("#openSelect").click(function () {
                            var classId = $("#openSelect").attr("class")
                            if (classId === 'closebtn') {
                                $("#openSelect").addClass('openbtn').removeClass('closebtn')
                                $("#select-ecer ul").slideUp('300ms')
                            } else {
                                $("#openSelect").addClass('closebtn').removeClass('openbtn')
                                $("#select-ecer ul").slideDown('300ms')
                            }
                            $("#select-ecer ul li").click(function () {
                                 $("#openSelect").addClass('openbtn').removeClass('closebtn')
                                $("#select-ecer ul").slideUp('300ms')
                             })
                        })
                    </script>

                    
                    <!--新增归属分类 end  -->










                    <div class="item phone IEitem" style="width: 100%;justify-content: center;margin-top: 16px">
                        <div class="new-pro cur save">
                            <span class="fontdef  ">保存</span>
                        </div>
                        <div class="new-pro clear cur cancel">
                            <span class="fontdef  ">取消</span>
                        </div>
                    </div>

                </div>
            </div>

            <div class="Modal" id="delImg" style="display: none;">
                <div class="Modal-info">
                    <div class="setting">
                        <div class="info"><span>确定删除图片?</span></div>
                    </div>
                    <div class="btntab">
                        <div class="fontdef complete cur" id="del_img">确定</div>
                        <div class="fontdef clear cur closeModal">取消</div>
                    </div>
                </div>
            </div>
        </section>
        <script type="text/javascript" src="./产品编辑_files/Editor.js.下载"></script>
        <script type="text/javascript" src="./产品编辑_files/ajaxfileupload.js.下载"></script>
        <script>
            var lang = $('#lang').val()
            var langTip = new Object();
            if (lang == 'en') {
                langTip.add_product_err = "Add product error!";
                langTip.delete = "Delete";
                langTip.upload_err = "File size cannot exceed 10MB!";
                langTip.tip_choose = "Please choose a file!";
                langTip.pic_lot = "Upload up to 5 images!";
                langTip.title = "Product titles cannot be empty!";
                langTip.picture = "Product pictures cannot be empty!";
            } else {
                langTip.add_product_err = "产品新增失败";
                langTip.delete = "删除";
                langTip.upload_err = "文件大小不能超过10M！";
                langTip.tip_choose = "请先选择文件!";
                langTip.pic_lot = "最多上传5张图片!";
                langTip.title = "产品标题不能为空!";
                langTip.picture = "产品图片不能为空!";
            }


            var fileId;
            var rang;
            var editorText = '<p>撒打发士大夫啊手动阀 撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀撒打发士大夫啊手动阀&nbsp;</p>';
            editor.txt.html(editorText);
            //返回
            $('.cancel').click(function () {
                window.location.href = '/index.php?r=product/manage&page=1';
            })

            //响应上传按钮
            $('.upload').click(function () {
                var imgNum = $('.imgupload li').length;
                if (imgNum > 5) {
                    Alert(langTip.pic_lot)
                } else {
                    fileId = 'upload';
                    $('#file')[0].click();
                }
            })
            //产品保存
            var isSubmit = false;  //判断当前产品是否已经提交
            $('.save').click(function () {
                if (!isSubmit) {
                    isSubmit = true;
                    var content = '';
                    if ($('.edit-main .prod-edit .pc').css('display') == 'block') {
                        content = editor.txt.html();
                    }
                    if ($('.edit-main .prod-edit .phone').css('display') == 'block') {
                        content = $('#content').html();
                    }

                    var imgpath = [];

                    $("input[name='images']").each(function (index, dom) {
                        imgpath.push($(dom).val());
                    })

                    var data = {
                        'pid': $('#pid').val(),
                        'title': $.trim($('#title').val()),
                        'imgpath': imgpath,
                        'content': content
                    }

                    if (!data.title.length) {
                        Alert(langTip.title);
                        isSubmit = false;
                        return false;
                    }

                    if (!data.imgpath.length) {
                        Alert(langTip.picture);
                        isSubmit = false;
                        return false;
                    }

                    var url = '/index.php?r=product/save';
                    $("#title_error").text('');
                    $("#words_error").text('');
                    $.post(url, data, function (res) {
                        if (res.code == 200) {
                            window.location.href = '/index.php?r=product/manage&page=1';
                        } else if (res.code == -2) {
                            isSubmit = false;
                            $("#words_error").text(res.msg).css("color", "red");
                        } else if ([-3, -4, -5, -6].indexOf(res.code) >= 0) {
                            isSubmit = false;
                            $("#title_error").text(res.msg).css("color", "red");
                        } else if (res.code == -7) {
                            isSubmit = false;
                            Alert(res.msg);
                        } else {
                            isSubmit = false;
                            Alert(langTip.add_product_err);
                        }
                    }, 'json')
                }
            })

            //图片删除
            var delPic;
            $(".imgupload").on('click', '.del', function (e) {
                delPic = $(this);
                $("#delImg").fadeIn("300")
                e.stopPropagation()

            })

            $("#del_img").click(function () {
                delPic.parent().remove();
                $("#delImg").fadeOut("300")

                var imgLength = $('.imgupload li').length;
                if (imgLength < 6) {
                    $('.imgupload .upload').show();
                }
            })

            //换行
            $('#line_feed').click(function () {
                $('#content').append('<div><br></div>');
            })


            //手机模式下，文本框插入图片
            $('#insert_pic').click(function () {
                fileId = 'insert_pic';
                $('#file')[0].click();
            })

            // 编辑框点击事件
            $('#content').click(function () {
                // 获取选定对象
                var selection = getSelection()
                // 设置最后光标对象
                lastEditRange = selection.getRangeAt(0)
            })

            // 编辑框按键弹起事件
            $('#content').keyup(function () {
                // 获取选定对象
                var selection = getSelection()
                // 设置最后光标对象
                lastEditRange = selection.getRangeAt(0)
            })

            //图片上传
            function uploadImg() {
                if ($("#file").val() != "") {
                    $.ajaxFileUpload({
                        type: "POST",
                        url: '/index.php?r=upload/imgupload',
                        dataType: "json",
                        fileElementId: "file",  // 文件的id
                        success: function (res) {
                            if (res.code == 200) {
                                if (fileId == 'insert_pic') {
                                    //详情描述插入图片
                                    var html = '<img style="width: auto;height: auto;max-width: 100%;max-height: 100%;" src="' + res.data.imgpath + '" alt="">';
                                    insertHtmlAtCaret(html);
                                } else {
                                    //产品图片
                                    var html = '<li>' +
                                        '<img src="' + res.data.imgpath + '" alt="">' +
                                        '<input type="hidden" value="' + res.data.imgpath + '" name="images" >' +
                                        '<div class="del cur"><i class="iconfont icon-shanchu"></i> <span>' + langTip.delete + '</span></div>' +
                                        '</li>';
                                    $('.upload').before(html);
                                    var imgLength = $('.imgupload li').length;
                                    if (imgLength >= 6) {
                                        $('.imgupload .upload').hide();
                                    }
                                }
                            } else {
                                Alert(res.message);
                            }
                        },
                        error: function (e) {
                            Alert(langTip.upload_err);
                        }
                    });
                } else {
                    Alert(langTip.tip_choose);
                }
            }

        </script>
        <div class="Modal" id="notice" style="z-index: 999999">
            <div class="Modal-info">
                <div class="setting">
                    <!-- 提示信息-->
                    <div class="info"><span class="spantxt name"></span>
                    </div>
                </div>
                <div class="btntab">
                    <div class="fontdef complete cur">确定</div>
                </div>
            </div>
        </div>
        <div class="Modal" id="company_name">
            <div class="Modal-info">
                <div class="setting">
                    <!-- 提示信息-->
                    <div class="info" style="height: auto;margin-top: 30px">
                        <span class="spantxt">请完善公司名称</span>
                    </div>
                    <div class="setting-name" style="height: auto;margin-top: 30px;">
                        <div style="width: 80%">
                            <input id="corpname" type="text" style="margin: 0px;width: 100%"
                                autocomplete="new-password">
                            <span class="line" style="width: 100%"></span>
                        </div>
                    </div>
                </div>
                <div class="btntab">
                    <div class="fontdef complete cur" id="uc_p_sure">确定</div>
                </div>
            </div>
        </div>
    </div>


    <script>
        window.onload = function () {
            $("body").show();
        }

        // 监听浏览器回退事件,返回上一级页面刷新

        if (window.name != "refresh") {
            location.reload();
            window.name = "refresh";
        }
        else {
            window.name = "";
        }

    </script>
    <script type="text/javascript" src="./产品编辑_files/bootstrap.min.js.下载"></script>
    <script type="text/javascript" src="./产品编辑_files/common.js.下载"></script>

    <script type="text/javascript">
        function swtich(lang) {
            var oUrl = this.location.href.toString();
            var re = eval('/(lang=)([^&]*)/gi');
            if (oUrl.indexOf("r=") < 0) {
                var nUrl = oUrl + '/index.php?r=product/index';
            } else {
                var nUrl = oUrl;
            }
            if (oUrl.indexOf("lang") >= 0) {
                nUrl = nUrl.replace(re, 'lang=' + lang);
            } else {
                nUrl = nUrl + '&lang=' + lang;
            }
            window.location.href = nUrl;
        }

        //判断用户公司名称是否存在，不存在则强制跳转完善公司信息
        var company_name = "false";
        if (company_name == 'true') {
            $("#company_name").fadeIn("300")
        }

        $('#uc_p_sure').click(function () {
            var url = '/index.php?r=company/editCompanyName';
            var corpname = $.trim($('#corpname').val());
            if (!corpname.length) {
                Alert("公司名称不能为空");
                return false;
            }
            $.post(url, { 'corpname': corpname }, function (res) {
                Alert(res.message);
                if (res.status == '200') {
                    $("#company_name").fadeOut("300");
                }
            }, 'json')
        })

    //阻止ios10以上浏览器缩放y
    // html加载完成在显示body
    // window.οnlοad=function () {


        // document.addEventListener('touchstart',function (event) {
        //     if(event.touches.length>1){
        //         event.preventDefault();
        //     }
        // })
        // var lastTouchEnd=0;
        // document.addEventListener('touchend',function (event) {
        //     var now=(new Date()).getTime();
        //     if(now-lastTouchEnd<=300){
        //         event.preventDefault();
        //     }
        //     lastTouchEnd=now;
        // },false)
// }
    </script>


    </body>

</html>